﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp.拦截器
{
    public abstract class AbstractBusinessChain<TPluginContext> : IBusinessChain<TPluginContext>
    {
        protected Action<TPluginContext> Action { get; }

        protected AbstractBusinessChain(Action<TPluginContext> action)
        {
            Action = action ?? throw new ArgumentNullException(nameof(action));
        }

        public virtual void Run(TPluginContext context)
        {
            Action(context);
        }

        public virtual void Run(TPluginContext context, Action<TPluginContext> action)
        {
            Action(context);
            action(context);
        }
    }
}
